package com.ruoyi.surfacewater.service.impl;

import com.ruoyi.base.mapper.PublicToolsMapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.js.ItemCodeOverData;
import com.ruoyi.common.utils.js.Standard;
import com.ruoyi.common.utils.js.WaterLevelCompute;
import com.ruoyi.surfacewater.domain.BusBasmonthlycumulativedata;
import com.ruoyi.surfacewater.mapper.BusMonthlycumulativedataMapper;
import com.ruoyi.surfacewater.service.BusMonthlycumulativedataService;
import com.ruoyi.surfacewater.service.MaunalComparisonOfWaterQualityService;
import com.ruoyi.utli.SegmentFormula;
import com.ruoyi.utli.service.SegmentUtliService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class BusMonthlycumulativedataServiceImpl implements BusMonthlycumulativedataService {

    @Autowired
    private SegmentFormula segmentFormula;

    @Autowired
    private SegmentUtliService segmentUtliService;//断面工具类
    @Autowired
    private BusMonthlycumulativedataMapper busMonthlycumulativedataMapper;

    @Autowired
    private PublicToolsMapper publicToolsMapper;

    @Autowired
    private MaunalComparisonOfWaterQualityService maunalComparisonOfWaterQualityService;


    @Override
    public void moonAssessTypeSegmen() {
//根据国 省 市 全部考核断面  手工断面 类型查询到对应断面id AssessTownCodesegment 考核  WqBasSegmentNameAll 手工
        Map<String, Object> AssessTownCodesegmentmap = new HashMap<>();
        AssessTownCodesegmentmap.put("Type", "CountyCode");
        //查询全部考核断面
        List<Map<String, Object>> allassessTypelist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> allassessTypesegmenfenzu = segmentFormula.Segmenfenzu(allassessTypelist);
        AssessTownCodesegmentmap.put("AssessTypeCode", "0");//查询国考数据
        List<Map<String, Object>> countrylist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> countrylistsegmenfenzu = segmentFormula.Segmenfenzu(countrylist);
        AssessTownCodesegmentmap.put("AssessTypeCode", "1");//查询省考数据
        List<Map<String, Object>> economizelist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> economizelistsegmenfenzu = segmentFormula.Segmenfenzu(economizelist);

        AssessTownCodesegmentmap.put("AssessTypeCode", "2");//查询市考数据
        List<Map<String, Object>> marketlist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> marketlistsegmenfenzu = segmentFormula.Segmenfenzu(marketlist);

        Map<String, Object> WqBasSegmentNameAllmap = new HashMap<>();
        WqBasSegmentNameAllmap.put("segmentType", "IsManual");//查询所有手工断面
        WqBasSegmentNameAllmap.put("segmentTypes", "IsManualIsDrink");//查询所有手工断面
        WqBasSegmentNameAllmap.put("semen", "IsManual");//查询所有手工断面
        List<Map<String, Object>> WqBasSegmentNameAlllistdata = new ArrayList<>();
        List<Map> WqBasSegmentNameAlllist = segmentUtliService.WqBasSegmentid(WqBasSegmentNameAllmap);
        if (WqBasSegmentNameAlllist != null && WqBasSegmentNameAlllist.size() > 0) {
            for (Map data : WqBasSegmentNameAlllist) {
                WqBasSegmentNameAlllistdata.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> WqBasSegmentNameAlllistsegmenfenzu = segmentFormula.Segmenfenzu(WqBasSegmentNameAlllistdata);

        //上面数据处理完成后进行不同数据类型处理
        //国考断面数据处理
        insertWq_data_basmonthlycumulativedata(countrylistsegmenfenzu, "0");
        //省考
        insertWq_data_basmonthlycumulativedata(economizelistsegmenfenzu, "1");
        //市考
        insertWq_data_basmonthlycumulativedata(marketlistsegmenfenzu, "2");
        //全部考核断面
        insertWq_data_basmonthlycumulativedata(allassessTypesegmenfenzu, "3");
        //手工断面
        insertWq_data_basmonthlycumulativedata(WqBasSegmentNameAlllistsegmenfenzu, "4");
        //不同断面数据入库
        insertWq_data_basmonthlycumulativedata(WqBasSegmentNameAlllistsegmenfenzu, "5");


        List<Map<String, Object>> gslist = new ArrayList<>();
        if (countrylist != null && countrylist.size() > 0) {
            for (Map<String, Object> data : countrylist) {
                gslist.add(data);
            }
        }
        if (economizelist != null && economizelist.size() > 0) {
            for (Map<String, Object> data : economizelist) {
                gslist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> gssegmenfenzu = segmentFormula.Segmenfenzu(gslist);
        //国省
        insertWq_data_basmonthlycumulativedata(gssegmenfenzu, "6");
        //国市
        List<Map<String, Object>> gshilist = new ArrayList<>();
        if (countrylist != null && countrylist.size() > 0) {
            for (Map<String, Object> data : countrylist) {
                gshilist.add(data);
            }
        }
        if (marketlist != null && marketlist.size() > 0) {
            for (Map<String, Object> data : marketlist) {
                gshilist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> gshilistsegmenfenzu = segmentFormula.Segmenfenzu(gshilist);
        insertWq_data_basmonthlycumulativedata(gshilistsegmenfenzu, "7");
        //省市
        List<Map<String, Object>> sshilist = new ArrayList<>();
        if (economizelist != null && economizelist.size() > 0) {
            for (Map<String, Object> data : economizelist) {
                sshilist.add(data);
            }
        }
        if (marketlist != null && marketlist.size() > 0) {
            for (Map<String, Object> data : marketlist) {
                sshilist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> sshilistsegmenfenzu = segmentFormula.Segmenfenzu(sshilist);
        insertWq_data_basmonthlycumulativedata(sshilistsegmenfenzu, "8");

        //国考断面数据处理
        insertWq_data_basmonthlycumulativedata(countrylistsegmenfenzu, "9");
        //省考
        insertWq_data_basmonthlycumulativedata(economizelistsegmenfenzu, "10");
        //市考
        insertWq_data_basmonthlycumulativedata(marketlistsegmenfenzu, "11");
    }



    public void insertWq_data_basmonthlycumulativedata(Map<String, Object> mapdatal, String datatype) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> minmaxSampleDate = busMonthlycumulativedataMapper.minmaxSampleDate();//获取最小最大数据
        Object minSampleDate = minmaxSampleDate.get("minSampleDate");//开始月份
        Object maxSampleDate = minmaxSampleDate.get("maxSampleDate");//结束月份
        Object maxmonSampleDate = minmaxSampleDate.get("maxmonSampleDate");//月份
        Object minyarSampleDate = minmaxSampleDate.get("minyarSampleDate");//开始年份
        Object maxyarSampleDate = minmaxSampleDate.get("maxyarSampleDate");//结束年份
        //查询数据表中是否存在数据如果存在就查询当前月的数据，如果不存在就循环月数据进行入库
        List<String> alllistsss = (List<String>) mapdatal.get("alllists");//河流对应id
        if(datatype.equals("5")){
            map.put("SegmentIDs", alllistsss);
        }
        map.put("datatype", datatype);
        List<Map<String, Object>> wq_data_basmonthlycumulativedataByConditionlist = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(map);
        Boolean moondata = true;
        if (wq_data_basmonthlycumulativedataByConditionlist != null && wq_data_basmonthlycumulativedataByConditionlist.size() > 0) {
            moondata = false;
        }
        if (moondata) {
            //获取年份
            List<String> years = DateUtils.getYears(String.valueOf(minyarSampleDate), String.valueOf(maxyarSampleDate));
            //根据上面年份进行循环
            if (years != null && years.size() > 0) {
                for (String yeardata : years) {
                    for (int i = 1; i <= 12; i++) {
                        String kstime = yeardata + "-01";//开始时间
                        String jstime = null;
                        String jstimes = null;
                        String jstimess = null;
                        if(yeardata.equals("2025")){
                            if(i==9){
                                System.out.println("");
                            }
                        }
                        if (i <= 9) {
                            jstime = yeardata + "-0" + (i);//结束时间
                            jstimes = "0" + (i);//结束时间
                        } else {
                            jstime = yeardata + "-" + (i );//结束时间
                            jstimes = String.valueOf((i ));//结束时间
                        }
                        Boolean sj=true;
                        if(maxSampleDate!=null&&!"".equals(maxSampleDate)){
                            String s = String.valueOf(maxSampleDate);
                            if(s.equals(jstime)){
                                // sj=false;
                            }
                        }
                        if(sj){

                            //判断传入的数据不能为空
                            if (mapdatal != null && mapdatal.size() > 0) {
                                List<String> hlsegmeid = (List<String>) mapdatal.get("hlsegmeid");//河流对应id
                                List<String> hksegmeid = (List<String>) mapdatal.get("hksegmeid");//湖库对应id
                                List<String> alllists = (List<String>) mapdatal.get("alllists");//全部对应id
                                List<String> dxsegmeid = (List<String>) mapdatal.get("dxsegmeid");//湖库对应id

                                List<Map<String, Object>> segmedata = (List<Map<String, Object>>) mapdatal.get("segmedata");//湖库对应id
                                int hlsize = hlsegmeid.size();
                                int hksize = hksegmeid.size();
                                if (datatype.equals("9")) {
                                    if (alllists != null && alllists.size() > 0) {
                                        Date date = new Date();
                                        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                        String format = dfs.format(date);
                                        Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", format);
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                                        //wqDataBasmonthlycumulativedataMapper.deleteWq_data_basmonthlycumulativedataByIdSampleDate(deleteWq_data_basmonthlycumulativedataByIdSampleDatemap);

                                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                        avgDatasegmenthl.put("segmentIds", alllists);
                                        avgDatasegmenthl.put("ksTime", kstime);
                                        avgDatasegmenthl.put("jsTime", jstime);
                                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                                dataday.setDatatype(datatype);
                                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                                Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                                Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                                //数据存入进行插入
                                                if (moonime != null && !"".equals(moonime)) {
                                                    dataday.setMonths(String.valueOf(jstimes));
                                                    if (jstimes.equals("01")) {
                                                        dataday.setAccumulatedmonths("01");
                                                    } else {
                                                        dataday.setAccumulatedmonths("01-" + jstimes);
                                                    }
                                                }
                                                if (moondatas != null && !"".equals(moondatas)) {
                                                    dataday.setSampledate(String.valueOf(jstime));
                                                }
                                                if (yeartime != null && !"".equals(yeartime)) {
                                                    dataday.setYeardata(String.valueOf(yeartime));
                                                }
                                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                                }
                                                if (itemCode != null && !"".equals(itemCode)) {
                                                    dataday.setItemcode(String.valueOf(itemCode));
                                                }
                                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                                }
                                                if (assessType != null && !"".equals(assessType)) {
                                                    dataday.setAssesstype(String.valueOf(assessType));
                                                }
                                                if (itemName != null && !"".equals(itemName)) {
                                                    dataday.setItemname(String.valueOf(itemName));
                                                }
                                                if (county != null && !"".equals(county)) {
                                                    dataday.setCounty(String.valueOf(county));
                                                }
                                                if (countyCode != null && !"".equals(countyCode)) {
                                                    dataday.setCountycode(String.valueOf(countyCode));
                                                }

                                                if (riverID != null && !"".equals(riverID)) {
                                                    dataday.setRiverid(String.valueOf(riverID));
                                                }
                                                if (riverName != null && !"".equals(riverName)) {
                                                    dataday.setRivername(String.valueOf(riverName));
                                                }
                                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                                //调用工具类返回计算标准数据
                                                Map segmentStandardValuemap = new HashMap();
                                                segmentStandardValuemap.put("ItemCode", itemCode);
                                                segmentStandardValuemap.put("ID", id);
                                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);

                                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                if (integer != null) {
                                                    integer = integer;//断面计算出的级别
                                                } else {
                                                    //断面计算出的级别
                                                    integer = 0;
                                                }
                                                dataday.setQualitylevel(String.valueOf(integer));
                                                //转换水质级别名称
                                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                                dataday.setQualitylevelname(LevelName);
                                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                    }
                                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                    }
                                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                    }
                                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                    }
                                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                    }

                                                    //是否超标进行判断是否数据为空
                                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                    }
                                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                    }
                                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                    }
                                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                    }
                                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                    }
                                                }

                                                //上面数据处理完成后进行数据判断插入
                                                //数据特殊处理当前时间累计
                                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", moondatas);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "1");
                                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {

                                                } else {
                                                    dataday.setId(UUID.randomUUID().toString());
                                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                                }
                                            }
                                        }
                                    }
                                }
                                if (datatype.equals("10")) {
                                    if (alllists != null && alllists.size() > 0) {
                                        Date date = new Date();
                                        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                        String format = dfs.format(date);
                                        Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", format);
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                                        //wqDataBasmonthlycumulativedataMapper.deleteWq_data_basmonthlycumulativedataByIdSampleDate(deleteWq_data_basmonthlycumulativedataByIdSampleDatemap);

                                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                        avgDatasegmenthl.put("segmentIds", alllists);
                                        avgDatasegmenthl.put("ksTime", kstime);
                                        avgDatasegmenthl.put("jsTime", jstime);
                                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                                dataday.setDatatype(datatype);
                                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                                Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                                Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                                //数据存入进行插入
                                                if (moonime != null && !"".equals(moonime)) {
                                                    dataday.setMonths(String.valueOf(jstimes));
                                                    if (jstimes.equals("01")) {
                                                        dataday.setAccumulatedmonths("01");
                                                    } else {
                                                        dataday.setAccumulatedmonths("01-" + jstimes);
                                                    }
                                                }
                                                if (moondatas != null && !"".equals(moondatas)) {
                                                    dataday.setSampledate(String.valueOf(jstime));
                                                }
                                                if (yeartime != null && !"".equals(yeartime)) {
                                                    dataday.setYeardata(String.valueOf(yeartime));
                                                }
                                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                                }
                                                if (itemCode != null && !"".equals(itemCode)) {
                                                    dataday.setItemcode(String.valueOf(itemCode));
                                                }
                                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                                }
                                                if (assessType != null && !"".equals(assessType)) {
                                                    dataday.setAssesstype(String.valueOf(assessType));
                                                }
                                                if (itemName != null && !"".equals(itemName)) {
                                                    dataday.setItemname(String.valueOf(itemName));
                                                }
                                                if (county != null && !"".equals(county)) {
                                                    dataday.setCounty(String.valueOf(county));
                                                }
                                                if (countyCode != null && !"".equals(countyCode)) {
                                                    dataday.setCountycode(String.valueOf(countyCode));
                                                }

                                                if (riverID != null && !"".equals(riverID)) {
                                                    dataday.setRiverid(String.valueOf(riverID));
                                                }
                                                if (riverName != null && !"".equals(riverName)) {
                                                    dataday.setRivername(String.valueOf(riverName));
                                                }
                                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                                //调用工具类返回计算标准数据
                                                Map segmentStandardValuemap = new HashMap();
                                                segmentStandardValuemap.put("ItemCode", itemCode);
                                                segmentStandardValuemap.put("ID", id);
                                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                if (integer != null) {
                                                    integer = integer;//断面计算出的级别
                                                } else {
                                                    //断面计算出的级别
                                                    integer = 0;
                                                }
                                                dataday.setQualitylevel(String.valueOf(integer));
                                                //转换水质级别名称
                                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                                dataday.setQualitylevelname(LevelName);
                                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                    }
                                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                    }
                                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                    }
                                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                    }
                                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                    }

                                                    //是否超标进行判断是否数据为空
                                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                    }
                                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                    }
                                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                    }
                                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                    }
                                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                    }


                                                }

                                                //上面数据处理完成后进行数据判断插入
                                                //数据特殊处理当前时间累计

                                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", moondatas);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "1");
                                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {

                                                } else {
                                                    dataday.setId(UUID.randomUUID().toString());
                                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                                }
                                            }
                                        }
                                    }
                                }
                                if (datatype.equals("11")) {
                                    if (alllists != null && alllists.size() > 0) {
                                        Date date = new Date();
                                        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                        String format = dfs.format(date);
                                        Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", format);
                                        deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                                        //wqDataBasmonthlycumulativedataMapper.deleteWq_data_basmonthlycumulativedataByIdSampleDate(deleteWq_data_basmonthlycumulativedataByIdSampleDatemap);

                                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                        avgDatasegmenthl.put("segmentIds", alllists);
                                        avgDatasegmenthl.put("ksTime", kstime);
                                        avgDatasegmenthl.put("jsTime", jstime);
                                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                                dataday.setDatatype(datatype);
                                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                                Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                                Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                                //数据存入进行插入
                                                if (moonime != null && !"".equals(moonime)) {
                                                    dataday.setMonths(String.valueOf(jstimes));
                                                    if (jstimes.equals("01")) {
                                                        dataday.setAccumulatedmonths("01");
                                                    } else {
                                                        dataday.setAccumulatedmonths("01-" + jstimes);
                                                    }
                                                }
                                                if (moondatas != null && !"".equals(moondatas)) {
                                                    dataday.setSampledate(String.valueOf(jstime));
                                                }
                                                if (yeartime != null && !"".equals(yeartime)) {
                                                    dataday.setYeardata(String.valueOf(yeartime));
                                                }
                                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                                }
                                                if (itemCode != null && !"".equals(itemCode)) {
                                                    dataday.setItemcode(String.valueOf(itemCode));
                                                }
                                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                                }
                                                if (assessType != null && !"".equals(assessType)) {
                                                    dataday.setAssesstype(String.valueOf(assessType));
                                                }
                                                if (itemName != null && !"".equals(itemName)) {
                                                    dataday.setItemname(String.valueOf(itemName));
                                                }
                                                if (county != null && !"".equals(county)) {
                                                    dataday.setCounty(String.valueOf(county));
                                                }
                                                if (countyCode != null && !"".equals(countyCode)) {
                                                    dataday.setCountycode(String.valueOf(countyCode));
                                                }

                                                if (riverID != null && !"".equals(riverID)) {
                                                    dataday.setRiverid(String.valueOf(riverID));
                                                }
                                                if (riverName != null && !"".equals(riverName)) {
                                                    dataday.setRivername(String.valueOf(riverName));
                                                }
                                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                                //调用工具类返回计算标准数据
                                                Map segmentStandardValuemap = new HashMap();
                                                segmentStandardValuemap.put("ItemCode", itemCode);
                                                segmentStandardValuemap.put("ID", id);
                                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                if (integer != null) {
                                                    integer = integer;//断面计算出的级别
                                                } else {
                                                    //断面计算出的级别
                                                    integer = 0;
                                                }
                                                dataday.setQualitylevel(String.valueOf(integer));
                                                //转换水质级别名称
                                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                                dataday.setQualitylevelname(LevelName);
                                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                    }
                                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                    }
                                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                    }
                                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                    }
                                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                    }

                                                    //是否超标进行判断是否数据为空
                                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                    }
                                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                    }
                                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                    }
                                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                    }
                                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                    }


                                                }

                                                //上面数据处理完成后进行数据判断插入
                                                //数据特殊处理当前时间累计

                                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", moondatas);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "1");
                                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {

                                                } else {
                                                    dataday.setId(UUID.randomUUID().toString());
                                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                                }
                                            }
                                        }
                                    }
                                }
                                //获取到对应id之后进行数据均值处理
                                if (hlsegmeid != null && hlsegmeid.size() > 0) {
                                    Date date = new Date();
                                    SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                    String format = dfs.format(date);
                                    Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", format);
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SegmentCategory", "1");
                                    //wqDataBasmonthlycumulativedataMapper.deleteWq_data_basmonthlycumulativedataByIdSampleDate(deleteWq_data_basmonthlycumulativedataByIdSampleDatemap);

                                    Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                    avgDatasegmenthl.put("segmentIds", hlsegmeid);
                                    avgDatasegmenthl.put("segmentdatatype", datatype);
                                    avgDatasegmenthl.put("ksTime", kstime);
                                    avgDatasegmenthl.put("jsTime", jstime);
                                    if (datatype.equals("5")) {
                                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        //avgDatasegmenthl.put("segmentBussinessCategoryCode", "BussinessCategoryCode");
                                    }
                                    List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                                    if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                        for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                            BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                            dataday.setSegmentcategory("1");
                                            dataday.setDatatype(datatype);
                                            Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                            Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                            Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                            Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                            Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                            Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                            Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                            Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                            Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                            Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                            Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                            Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                            Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                            Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                            Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                            Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                            Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                            //数据存入进行插入
                                            if (moonime != null && !"".equals(moonime)) {
                                                dataday.setMonths(String.valueOf(jstimes));
                                                if (jstimes.equals("01")) {
                                                    dataday.setAccumulatedmonths("01");
                                                } else {
                                                    dataday.setAccumulatedmonths("01-" + jstimes);
                                                }
                                            }
                                            if (moondatas != null && !"".equals(moondatas)) {
                                                dataday.setSampledate(String.valueOf(jstime));
                                            }
                                            if (yeartime != null && !"".equals(yeartime)) {
                                                dataday.setYeardata(String.valueOf(yeartime));
                                            }
                                            if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                            }
                                            if (itemCode != null && !"".equals(itemCode)) {
                                                dataday.setItemcode(String.valueOf(itemCode));
                                            }
                                            if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                            }
                                            if (assessType != null && !"".equals(assessType)) {
                                                dataday.setAssesstype(String.valueOf(assessType));
                                            }
                                            if (itemName != null && !"".equals(itemName)) {
                                                dataday.setItemname(String.valueOf(itemName));
                                            }
                                            if (county != null && !"".equals(county)) {
                                                dataday.setCounty(String.valueOf(county));
                                            }
                                            if (countyCode != null && !"".equals(countyCode)) {
                                                dataday.setCountycode(String.valueOf(countyCode));
                                            }
                                            if (datatype.equals("5")) {
                                                if (id != null && !"".equals(id)) {
                                                    dataday.setSegmentid(String.valueOf(id));
                                                }
                                                if (segmentName != null && !"".equals(segmentName)) {
                                                    dataday.setSegmentname(String.valueOf(segmentName));
                                                }
                                            }
                                            if (riverID != null && !"".equals(riverID)) {
                                                dataday.setRiverid(String.valueOf(riverID));
                                            }
                                            if (riverName != null && !"".equals(riverName)) {
                                                dataday.setRivername(String.valueOf(riverName));
                                            }
                                            if (countyCode != null && !"".equals(countyCode)) {
                                                List<Map<String, Object>> list = new ArrayList<>();
                                                if (segmedata != null && segmedata.size() > 0) {
                                                    //分组判断，stream流
                                                    Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                                            segmedata.stream().collect(
                                                                    Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                                            );
                                                    list = sunmapsSegmentID.get(countyCode);
                                                }
                                                String datasize = "0";
                                                if (list != null && list.size() > 0) {
                                                    for (Map<String, Object> listdata : list) {
                                                        Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                                        Object countyCode1 = listdata.get("CountyCode");//区划编码
                                                        Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                                        datasize = String.valueOf(hldatasize);
                                                    }
                                                }
                                                dataday.setStandby(String.valueOf(datasize));
                                            }


                                            //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                            //调用工具类返回计算标准数据
                                            Map segmentStandardValuemap = new HashMap();
                                            segmentStandardValuemap.put("ItemCode", itemCode);
                                            segmentStandardValuemap.put("ID", id);
                                            List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                            Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                            //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                            if (integer != null) {
                                                integer = integer;//断面计算出的级别
                                            } else {
                                                //断面计算出的级别
                                                integer = 0;
                                            }
                                            dataday.setQualitylevel(String.valueOf(integer));
                                            //转换水质级别名称
                                            String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                            dataday.setQualitylevelname(LevelName);
                                            //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                            Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                            if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                    dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                }
                                                if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                    dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                }
                                                if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                    dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                }
                                                if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                    dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                }
                                                if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                    dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                }

                                                //是否超标进行判断是否数据为空
                                                if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                    dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                }
                                                if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                    dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                }
                                                if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                    dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                }
                                                if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                    dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                }
                                                if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                    dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                }
                                            }

                                            //上面数据处理完成后进行数据判断插入
                                            //数据特殊处理当前时间累计
                                            Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", jstime);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "1");
                                            if (datatype.equals("5")) {
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                                            }
                                            List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                            if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                                // System.out.println(findWq_data_basmonthlycumulativedataByConditionmap.toString());

                                            } else {
                                                dataday.setId(UUID.randomUUID().toString());
                                                busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                            }
                                        }
                                    }


                                }
                                if (hksegmeid != null && hksegmeid.size() > 0) {
                                    Date date = new Date();
                                    SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                    String format = dfs.format(date);
                                    Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", format);
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                                    deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SegmentCategory", "2");
                                    // wqDataBasmonthlycumulativedataMapper.deleteWq_data_basmonthlycumulativedataByIdSampleDate(deleteWq_data_basmonthlycumulativedataByIdSampleDatemap);

                                    Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                    avgDatasegmenthl.put("segmentIds", hksegmeid);
                                    avgDatasegmenthl.put("segmentdatatype", datatype);
                                    avgDatasegmenthl.put("ksTime", kstime);
                                    avgDatasegmenthl.put("jsTime", jstime);
                                    if (datatype.equals("5")) {
                                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        //avgDatasegmenthl.put("segmentBussinessCategoryCode", "BussinessCategoryCode");
                                    }
                                    List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                                    if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                        for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                            BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                            dataday.setSegmentcategory("2");
                                            dataday.setDatatype(datatype);
                                            Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                            Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                            Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                            Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                            Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                            Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                            Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                            Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                            Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                            Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                            Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                            Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                            Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                            Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                            Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                            Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                            Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                            //数据存入进行插入
                                            if (moonime != null && !"".equals(moonime)) {
                                                dataday.setMonths(String.valueOf(jstimes));
                                                if (jstimes.equals("01")) {
                                                    dataday.setAccumulatedmonths("01");
                                                } else {
                                                    dataday.setAccumulatedmonths("01-" + jstimes);
                                                }
                                            }
                                            if (moondatas != null && !"".equals(moondatas)) {
                                                dataday.setSampledate(String.valueOf(jstime));
                                            }
                                            if (yeartime != null && !"".equals(yeartime)) {
                                                dataday.setYeardata(String.valueOf(yeartime));
                                            }
                                            if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                            }
                                            if (itemCode != null && !"".equals(itemCode)) {
                                                dataday.setItemcode(String.valueOf(itemCode));
                                            }
                                            if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                            }
                                            if (assessType != null && !"".equals(assessType)) {
                                                dataday.setAssesstype(String.valueOf(assessType));
                                            }
                                            if (itemName != null && !"".equals(itemName)) {
                                                dataday.setItemname(String.valueOf(itemName));
                                            }
                                            if (county != null && !"".equals(county)) {
                                                dataday.setCounty(String.valueOf(county));
                                            }
                                            if (countyCode != null && !"".equals(countyCode)) {
                                                dataday.setCountycode(String.valueOf(countyCode));
                                            }
                                            if (datatype.equals("5")) {
                                                if (id != null && !"".equals(id)) {
                                                    dataday.setSegmentid(String.valueOf(id));
                                                }
                                                if (segmentName != null && !"".equals(segmentName)) {
                                                    dataday.setSegmentname(String.valueOf(segmentName));
                                                }
                                            }
                                            if (countyCode != null && !"".equals(countyCode)) {
                                                List<Map<String, Object>> list = new ArrayList<>();
                                                if (segmedata != null && segmedata.size() > 0) {
                                                    //分组判断，stream流
                                                    Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                                            segmedata.stream().collect(
                                                                    Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                                            );
                                                    list = sunmapsSegmentID.get(countyCode);
                                                }
                                                String datasize = "0";
                                                if (list != null && list.size() > 0) {
                                                    for (Map<String, Object> listdata : list) {
                                                        Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                                        Object countyCode1 = listdata.get("CountyCode");//区划编码
                                                        Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                                        datasize = String.valueOf(hkdatasize);
                                                    }
                                                }
                                                dataday.setStandby1(String.valueOf(datasize));
                                            }

                                            if (riverID != null && !"".equals(riverID)) {
                                                dataday.setRiverid(String.valueOf(riverID));
                                            }
                                            if (riverName != null && !"".equals(riverName)) {
                                                dataday.setRivername(String.valueOf(riverName));
                                            }
                                            //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                            //调用工具类返回计算标准数据
                                            Map segmentStandardValuemap = new HashMap();
                                            segmentStandardValuemap.put("ItemCode", itemCode);
                                            segmentStandardValuemap.put("ID", id);
                                            List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                            Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                            //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                            if (integer != null) {
                                                integer = integer;//断面计算出的级别
                                            } else {
                                                //断面计算出的级别
                                                integer = 0;
                                            }
                                            dataday.setQualitylevel(String.valueOf(integer));
                                            //转换水质级别名称
                                            String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                            dataday.setQualitylevelname(LevelName);
                                            //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                            Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                            if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                    dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                }
                                                if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                    dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                }
                                                if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                    dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                }
                                                if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                    dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                }
                                                if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                    dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                }

                                                //是否超标进行判断是否数据为空
                                                if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                    dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                }
                                                if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                    dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                }
                                                if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                    dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                }
                                                if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                    dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                }
                                                if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                    dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                }
                                            }

                                            //上面数据处理完成后进行数据判断插入
                                            //数据特殊处理当前时间累计
                                            Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", jstime);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                            findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "2");
                                            if (datatype.equals("5")) {
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                                            }
                                            List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                            if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {

                                            } else {
                                                dataday.setId(UUID.randomUUID().toString());
                                                busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                            }
                                        }
                                    }
                                }
                                if (datatype.equals("5")) {
                                    if (dxsegmeid != null && dxsegmeid.size() > 0) {
                                        Date date = new Date();
                                        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                                        // maxSampleDate
                                        Map<String, Object> minmaxSampleDatemap = new HashMap<>();
                                        minmaxSampleDatemap.put("SegmentIDs", dxsegmeid);
                                        Map<String, Object> stringObjectMap1 = busMonthlycumulativedataMapper.maxSampleDate(minmaxSampleDatemap);
                                        Object maxSampleDate1 = stringObjectMap1.get("maxSampleDate");
                                        String format = String.valueOf(maxSampleDate1);
                                        Integer year = DateUtils.getYear(format, "yyyy-MM");

                                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                                        avgDatasegmenthl.put("segmentIds", dxsegmeid);
                                        avgDatasegmenthl.put("segmentdatatype", datatype);
                                        if (datatype.equals("5")) {
                                            avgDatasegmenthl.put("segmentdatatype", "segmentId");
                                        }
                                        avgDatasegmenthl.put("ksTime", kstime);
                                        avgDatasegmenthl.put("jsTime", jstime);
                                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.sydavgDatasegment(avgDatasegmenthl);
                                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                                dataday.setSegmentcategory("3");
                                                dataday.setDatatype(datatype);
                                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                                // Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                                Object moonime = jstimes;//月份
                                                //Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                                Object moondatas = jstime;//年月
                                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                                //数据存入进行插入
                                                if (moonime != null && !"".equals(moonime)) {
                                                    String month = DateUtils.MONTH(String.valueOf(moondatas), "yyyy-MM");
                                                    dataday.setMonths(String.valueOf(month));
                                                    if (month.equals("01")) {
                                                        dataday.setAccumulatedmonths("01");
                                                    } else {
                                                        dataday.setAccumulatedmonths("01-" + month);
                                                    }
                                                }
                                                if (moondatas != null && !"".equals(moondatas)) {
                                                    dataday.setSampledate(String.valueOf(moondatas));
                                                }
                                                if (yeartime != null && !"".equals(yeartime)) {
                                                    dataday.setYeardata(String.valueOf(yeartime));
                                                }
                                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                                }
                                                if (itemCode != null && !"".equals(itemCode)) {
                                                    dataday.setItemcode(String.valueOf(itemCode));
                                                }
                                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                                }
                                                if (assessType != null && !"".equals(assessType)) {
                                                    dataday.setAssesstype(String.valueOf(assessType));
                                                }
                                                if (itemName != null && !"".equals(itemName)) {
                                                    dataday.setItemname(String.valueOf(itemName));
                                                }
                                                if (county != null && !"".equals(county)) {
                                                    dataday.setCounty(String.valueOf(county));
                                                }
                                                if (countyCode != null && !"".equals(countyCode)) {
                                                    dataday.setCountycode(String.valueOf(countyCode));
                                                }
                                                if (datatype.equals("5")) {
                                                    if (id != null && !"".equals(id)) {
                                                        dataday.setSegmentid(String.valueOf(id));
                                                    }
                                                    if (segmentName != null && !"".equals(segmentName)) {
                                                        dataday.setSegmentname(String.valueOf(segmentName));
                                                    }
                                                }
                                                if (countyCode != null && !"".equals(countyCode)) {
                                                    List<Map<String, Object>> list = new ArrayList<>();
                                                    if (segmedata != null && segmedata.size() > 0) {
                                                        //分组判断，stream流
                                                        Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                                                segmedata.stream().collect(
                                                                        Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                                                );
                                                        list = sunmapsSegmentID.get(countyCode);
                                                    }
                                                    String datasize = "0";
                                                    if (list != null && list.size() > 0) {
                                                        for (Map<String, Object> listdata : list) {
                                                            Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                                            Object countyCode1 = listdata.get("CountyCode");//区划编码
                                                            Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                                            datasize = String.valueOf(hkdatasize);
                                                        }
                                                    }
                                                    dataday.setStandby1(String.valueOf(datasize));
                                                }
                                                if (riverID != null && !"".equals(riverID)) {
                                                    dataday.setRiverid(String.valueOf(riverID));
                                                }
                                                if (riverName != null && !"".equals(riverName)) {
                                                    dataday.setRivername(String.valueOf(riverName));
                                                }
                                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                                //调用工具类返回计算标准数据
                                                Map segmentStandardValuemap = new HashMap();
                                                segmentStandardValuemap.put("ItemCode", itemCode);
                                                segmentStandardValuemap.put("ID", id);
                                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                if (integer != null) {
                                                    integer = integer;//断面计算出的级别
                                                } else {
                                                    //断面计算出的级别
                                                    integer = 0;
                                                }
                                                dataday.setQualitylevel(String.valueOf(integer));
                                                //转换水质级别名称
                                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                                dataday.setQualitylevelname(LevelName);
                                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                                    }
                                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                                    }
                                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                                    }
                                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                                    }
                                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                                    }

                                                    //是否超标进行判断是否数据为空
                                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                                    }
                                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                                    }
                                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                                    }
                                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                                    }
                                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                                    }
                                                }

                                                //上面数据处理完成后进行数据判断插入
                                                //数据特殊处理当前时间累计
                                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", dataday.getSampledate());
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "3");
                                                if (datatype.equals("5")) {
                                                    findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                                                }

                                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                                } else {
                                                    dataday.setId(UUID.randomUUID().toString());
                                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

        } else {
            Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
            deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", maxSampleDate);
            deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
            deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SegmentCategory", "3");
            //判断传入的数据不能为空
            if (mapdatal != null && mapdatal.size() > 0) {

                List<String> hlsegmeid = (List<String>) mapdatal.get("hlsegmeid");//河流对应id
                List<String> hksegmeid = (List<String>) mapdatal.get("hksegmeid");//湖库对应id
                List<String> dxsegmeid = (List<String>) mapdatal.get("dxsegmeid");//湖库对应id
                List<Map<String, Object>> segmedata = (List<Map<String, Object>>) mapdatal.get("segmedata");//湖库对应id
                int hlsize = hlsegmeid.size();
                int hksize = hksegmeid.size();
                //获取到对应id之后进行数据均值处理
                if (hlsegmeid != null && hlsegmeid.size() > 0) {
                    Date date = new Date();
                    SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                    // maxSampleDate
                    Map<String, Object> minmaxSampleDatemap = new HashMap<>();
                    minmaxSampleDatemap.put("SegmentIDs", hlsegmeid);
                    Map<String, Object> stringObjectMap1 = busMonthlycumulativedataMapper.maxSampleDate(minmaxSampleDatemap);
                    Object maxSampleDate1 = stringObjectMap1.get("maxSampleDate");
                    // String format = dfs.format(date);
                    Date parse = null;
                    try {
                        parse = dfs.parse(String.valueOf(maxSampleDate1));
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    String format = dfs.format(parse);

                    Integer year = DateUtils.getYear(format, "yyyy-MM");

                    Map<String, Object> avgDatasegmenthl = new HashMap<>();
                    avgDatasegmenthl.put("segmentIds", hlsegmeid);
                    avgDatasegmenthl.put("segmentdatatype", datatype);
                    avgDatasegmenthl.put("ksTime", year + "-01");
                    avgDatasegmenthl.put("jsTime", format);
                    if (datatype.equals("5")) {
                        avgDatasegmenthl.put("segmentdatatype", "segmentId");
                    }

                    List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                    if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                        for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                            BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                            dataday.setSegmentcategory("1");
                            dataday.setDatatype(datatype);
                            Object id = avgDatasegmenthllistdata.get("ID");//断面id
                            Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                            Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                            Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                            Object county = avgDatasegmenthllistdata.get("County");//区划名称
                            Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                            Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                            Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                            Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                            Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                            Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                            Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                            Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                            Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                            Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                            Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                            Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                            if (countyCode != null && !"".equals(countyCode)) {
                                List<Map<String, Object>> list = new ArrayList<>();
                                if (segmedata != null && segmedata.size() > 0) {
                                    //分组判断，stream流
                                    Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                            segmedata.stream().collect(
                                                    Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                            );
                                    list = sunmapsSegmentID.get(countyCode);
                                }
                                String datasize = "0";
                                if (list != null && list.size() > 0) {
                                    for (Map<String, Object> listdata : list) {
                                        Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                        Object countyCode1 = listdata.get("CountyCode");//区划编码
                                        Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                        datasize = String.valueOf(hldatasize);
                                    }
                                }
                                dataday.setStandby(String.valueOf(datasize));
                            }
                            //数据存入进行插入
                            if (moonime != null && !"".equals(moonime)) {
                                String month = DateUtils.MONTH(format, "yyyy-MM");
                                dataday.setMonths(String.valueOf(month));

                                if (month.equals("01")) {
                                    dataday.setAccumulatedmonths("01");
                                } else {
                                    dataday.setAccumulatedmonths("01-" + month);
                                }
                                //dataday.setAccumulatedmonths("01-02");
                            }
                            if (moondatas != null && !"".equals(moondatas)) {
                                dataday.setSampledate(format);
                                // dataday.setSampledate(String.valueOf(maxSampleDate));
                            }
                            if (yeartime != null && !"".equals(yeartime)) {
                                dataday.setYeardata(String.valueOf(yeartime));
                            }
                            if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                            }
                            if (itemCode != null && !"".equals(itemCode)) {
                                dataday.setItemcode(String.valueOf(itemCode));
                            }
                            if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                            }
                            if (assessType != null && !"".equals(assessType)) {
                                dataday.setAssesstype(String.valueOf(assessType));
                            }
                            if (itemName != null && !"".equals(itemName)) {
                                dataday.setItemname(String.valueOf(itemName));
                            }
                            if (county != null && !"".equals(county)) {
                                dataday.setCounty(String.valueOf(county));
                            }
                            if (countyCode != null && !"".equals(countyCode)) {
                                dataday.setCountycode(String.valueOf(countyCode));
                            }
                            if (datatype.equals("5")) {
                                if (id != null && !"".equals(id)) {
                                    dataday.setSegmentid(String.valueOf(id));
                                }
                                if (segmentName != null && !"".equals(segmentName)) {
                                    dataday.setSegmentname(String.valueOf(segmentName));
                                }
                            }
                            if (riverID != null && !"".equals(riverID)) {
                                dataday.setRiverid(String.valueOf(riverID));
                            }
                            if (riverName != null && !"".equals(riverName)) {
                                dataday.setRivername(String.valueOf(riverName));
                            }
                            //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                            //调用工具类返回计算标准数据
                            Map segmentStandardValuemap = new HashMap();
                            segmentStandardValuemap.put("ItemCode", itemCode);
                            segmentStandardValuemap.put("ID", id);
                            List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);

                            Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                            //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                            if (integer != null) {
                                integer = integer;//断面计算出的级别
                            } else {
                                //断面计算出的级别
                                integer = 0;
                            }
                            dataday.setQualitylevel(String.valueOf(integer));
                            //转换水质级别名称
                            String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                            dataday.setQualitylevelname(LevelName);
                            //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                            Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                            if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                    dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                }
                                if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                    dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                }
                                if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                    dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                }
                                if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                    dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                }
                                if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                    dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                }

                                //是否超标进行判断是否数据为空
                                if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                    dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                }
                                if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                    dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                }
                                if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                    dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                }
                                if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                    dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                }
                                if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                    dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                }
                            }

                            //上面数据处理完成后进行数据判断插入
                            //数据特殊处理当前时间累计
                            Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                            findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                            findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                            findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                            findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", dataday.getSampledate());
                            findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                            findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "1");
                            if (datatype.equals("5")) {
                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                            }

                            List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByConditionmap(findWq_data_basmonthlycumulativedataByConditionmap);
                            if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                Map<String, Object> stringObjectMap2 = wq_data_basmonthlycumulativedataByCondition.get(0);
                                if(stringObjectMap2!=null&&stringObjectMap2.size()>0){
                                    Object id1 = stringObjectMap2.get("id");
                                    if(id1!=null&&!"".equals(id1)){
                                        dataday.setId(String.valueOf(id1));
                                        busMonthlycumulativedataMapper.updateWq_data_basmonthlycumulativedata(dataday);
                                    }
                                }
                            } else {
                                dataday.setId(UUID.randomUUID().toString());
                                busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                            }
                        }
                    }


                }
                if (hksegmeid != null && hksegmeid.size() > 0) {
                    Date date = new Date();
                    SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                    // maxSampleDate
                    Map<String, Object> minmaxSampleDatemap = new HashMap<>();
                    minmaxSampleDatemap.put("SegmentIDs", hksegmeid);
                    Map<String, Object> stringObjectMap1 = busMonthlycumulativedataMapper.maxSampleDate(minmaxSampleDatemap);
                    if(stringObjectMap1!=null&&stringObjectMap1.size()>0){
                        Object maxSampleDate1 = stringObjectMap1.get("maxSampleDate");
                        // String format = dfs.format(date);
                        String format = String.valueOf(maxSampleDate1);
                        //String format = dfs.format(date);
                        Integer year = DateUtils.getYear(format, "yyyy-MM");
                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                        avgDatasegmenthl.put("segmentIds", hksegmeid);
                        avgDatasegmenthl.put("segmentdatatype", datatype);
                        if (datatype.equals("5")) {
                            avgDatasegmenthl.put("segmentdatatype", "segmentId");
                            // avgDatasegmenthl.put("segmentBussinessCategoryCode", "BussinessCategoryCode");
                        }
                        avgDatasegmenthl.put("ksTime", year + "-01");
                        avgDatasegmenthl.put("jsTime", format);
                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.avgDatasegment(avgDatasegmenthl);
                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                dataday.setSegmentcategory("2");
                                dataday.setDatatype(datatype);
                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                //数据存入进行插入
                                if (moonime != null && !"".equals(moonime)) {
                                    String month = DateUtils.MONTH(format, "yyyy-MM");
                                    dataday.setMonths(String.valueOf(month));
                                    if (month.equals("01")) {
                                        dataday.setAccumulatedmonths("01");
                                    } else {
                                        dataday.setAccumulatedmonths("01-" + month);
                                    }
                                }
                                if (moondatas != null && !"".equals(moondatas)) {
                                    dataday.setSampledate(format);
                                }
                                if (yeartime != null && !"".equals(yeartime)) {
                                    dataday.setYeardata(String.valueOf(yeartime));
                                }
                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                }
                                if (itemCode != null && !"".equals(itemCode)) {
                                    dataday.setItemcode(String.valueOf(itemCode));
                                }
                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                }
                                if (assessType != null && !"".equals(assessType)) {
                                    dataday.setAssesstype(String.valueOf(assessType));
                                }
                                if (itemName != null && !"".equals(itemName)) {
                                    dataday.setItemname(String.valueOf(itemName));
                                }
                                if (county != null && !"".equals(county)) {
                                    dataday.setCounty(String.valueOf(county));
                                }
                                if (countyCode != null && !"".equals(countyCode)) {
                                    dataday.setCountycode(String.valueOf(countyCode));
                                }
                                if (datatype.equals("5")) {
                                    if (id != null && !"".equals(id)) {
                                        dataday.setSegmentid(String.valueOf(id));
                                    }
                                    if (segmentName != null && !"".equals(segmentName)) {
                                        dataday.setSegmentname(String.valueOf(segmentName));
                                    }
                                }
                                if (countyCode != null && !"".equals(countyCode)) {
                                    List<Map<String, Object>> list = new ArrayList<>();
                                    if (segmedata != null && segmedata.size() > 0) {
                                        //分组判断，stream流
                                        Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                                segmedata.stream().collect(
                                                        Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                                );
                                        list = sunmapsSegmentID.get(countyCode);
                                    }
                                    String datasize = "0";
                                    if (list != null && list.size() > 0) {
                                        for (Map<String, Object> listdata : list) {
                                            Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                            Object countyCode1 = listdata.get("CountyCode");//区划编码
                                            Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                            datasize = String.valueOf(hkdatasize);
                                        }
                                    }
                                    dataday.setStandby1(String.valueOf(datasize));
                                }
                                if (riverID != null && !"".equals(riverID)) {
                                    dataday.setRiverid(String.valueOf(riverID));
                                }
                                if (riverName != null && !"".equals(riverName)) {
                                    dataday.setRivername(String.valueOf(riverName));
                                }
                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                //调用工具类返回计算标准数据
                                Map segmentStandardValuemap = new HashMap();
                                segmentStandardValuemap.put("ItemCode", itemCode);
                                segmentStandardValuemap.put("ID", id);
                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                if (integer != null) {
                                    integer = integer;//断面计算出的级别
                                } else {
                                    //断面计算出的级别
                                    integer = 0;
                                }
                                dataday.setQualitylevel(String.valueOf(integer));
                                //转换水质级别名称
                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                dataday.setQualitylevelname(LevelName);
                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                    }
                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                    }
                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                    }
                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                    }
                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                    }

                                    //是否超标进行判断是否数据为空
                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                    }
                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                    }
                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                    }
                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                    }
                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                    }
                                }

                                //上面数据处理完成后进行数据判断插入
                                //数据特殊处理当前时间累计
                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", dataday.getSampledate());
                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "2");
                                if (datatype.equals("5")) {
                                    findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                                }

                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByConditionmap(findWq_data_basmonthlycumulativedataByConditionmap);
                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                    Map<String, Object> stringObjectMap2 = wq_data_basmonthlycumulativedataByCondition.get(0);
                                    if(stringObjectMap2!=null&&stringObjectMap2.size()>0){
                                        Object id1 = stringObjectMap2.get("id");
                                        if(id1!=null&&!"".equals(id1)){
                                            dataday.setId(String.valueOf(id1));
                                            busMonthlycumulativedataMapper.updateWq_data_basmonthlycumulativedata(dataday);
                                        }
                                    }
                                } else {
                                    dataday.setId(UUID.randomUUID().toString());
                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                }
                            }
                        }
                    }
                }
                if (datatype.equals("5")) {
                    if (dxsegmeid != null && dxsegmeid.size() > 0) {
                        Date date = new Date();
                        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                        // maxSampleDate
                        Map<String, Object> minmaxSampleDatemap = new HashMap<>();
                        minmaxSampleDatemap.put("SegmentIDs", dxsegmeid);
                        Map<String, Object> stringObjectMap1 = busMonthlycumulativedataMapper.maxSampleDate(minmaxSampleDatemap);
                        Object maxSampleDate1 = stringObjectMap1.get("maxSampleDate");
                        String format = String.valueOf(maxSampleDate1);
                        Integer year = DateUtils.getYear(format, "yyyy-MM");

                        Map<String, Object> avgDatasegmenthl = new HashMap<>();
                        avgDatasegmenthl.put("segmentIds", dxsegmeid);
                        avgDatasegmenthl.put("segmentdatatype", datatype);
                        if (datatype.equals("5")) {
                            avgDatasegmenthl.put("segmentdatatype", "segmentId");
                            // avgDatasegmenthl.put("segmentBussinessCategoryCode", "BussinessCategoryCode");
                        }
                        avgDatasegmenthl.put("ksTime", year + "-01");
                        avgDatasegmenthl.put("jsTime", format);
                        List<Map<String, Object>> avgDatasegmenthllist = busMonthlycumulativedataMapper.sydavgDatasegment(avgDatasegmenthl);
                        if (avgDatasegmenthllist != null && avgDatasegmenthllist.size() > 0) {
                            for (Map<String, Object> avgDatasegmenthllistdata : avgDatasegmenthllist) {
                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                dataday.setSegmentcategory("3");
                                dataday.setDatatype(datatype);
                                Object id = avgDatasegmenthllistdata.get("ID");//断面id
                                Object segmentName = avgDatasegmenthllistdata.get("SegmentName");//断面名称
                                Object riverID = avgDatasegmenthllistdata.get("RiverID");//河流id
                                Object riverName = avgDatasegmenthllistdata.get("RiverName");//河流名称
                                Object county = avgDatasegmenthllistdata.get("County");//区划名称
                                Object countyCode = avgDatasegmenthllistdata.get("CountyCode");//区划编码
                                Object targetLevel = avgDatasegmenthllistdata.get("TargetLevel");//目标等级编码
                                Object targetLevelName = avgDatasegmenthllistdata.get("TargetLevelName");//目标等级
                                Object assessTypeCode = avgDatasegmenthllistdata.get("AssessTypeCode");//考核级别编码
                                Object assessType = avgDatasegmenthllistdata.get("AssessType");//考核级别
                                Object itemName = avgDatasegmenthllistdata.get("ItemName");//因子名称
                                Object itemCode = avgDatasegmenthllistdata.get("ItemCode");//因子编码
                                Object avgEffectiveValue = avgDatasegmenthllistdata.get("avgEffectiveValue");//均值数据
                                Object yeartime = avgDatasegmenthllistdata.get("yeartime");//年份
                                Object moonime = avgDatasegmenthllistdata.get("moonime");//月份
                                Object moondatas = avgDatasegmenthllistdata.get("moondata");//年月
                                Object itemCategroy = avgDatasegmenthllistdata.get("itemCategroy");//监测项水体类型  0 地表水 1地下水
                                //数据存入进行插入
                                if (moonime != null && !"".equals(moonime)) {
                                    String month = DateUtils.MONTH(format, "yyyy-MM");
                                    dataday.setMonths(String.valueOf(month));
                                    if (month.equals("01")) {
                                        dataday.setAccumulatedmonths("01");
                                    } else {
                                        dataday.setAccumulatedmonths("01-" + month);
                                    }
                                }
                                if (moondatas != null && !"".equals(moondatas)) {
                                    dataday.setSampledate(format);
                                }
                                if (yeartime != null && !"".equals(yeartime)) {
                                    dataday.setYeardata(String.valueOf(yeartime));
                                }
                                if (avgEffectiveValue != null && !"".equals(avgEffectiveValue)) {
                                    dataday.setEffectivevalue(new BigDecimal(String.valueOf(avgEffectiveValue)));
                                }
                                if (itemCode != null && !"".equals(itemCode)) {
                                    dataday.setItemcode(String.valueOf(itemCode));
                                }
                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                    dataday.setAssesstypecode(String.valueOf(assessTypeCode));
                                }
                                if (assessType != null && !"".equals(assessType)) {
                                    dataday.setAssesstype(String.valueOf(assessType));
                                }
                                if (itemName != null && !"".equals(itemName)) {
                                    dataday.setItemname(String.valueOf(itemName));
                                }
                                if (county != null && !"".equals(county)) {
                                    dataday.setCounty(String.valueOf(county));
                                }
                                if (countyCode != null && !"".equals(countyCode)) {
                                    dataday.setCountycode(String.valueOf(countyCode));
                                }
                                if (datatype.equals("5")) {
                                    if (id != null && !"".equals(id)) {
                                        dataday.setSegmentid(String.valueOf(id));
                                    }
                                    if (segmentName != null && !"".equals(segmentName)) {
                                        dataday.setSegmentname(String.valueOf(segmentName));
                                    }
                                }
                                if (countyCode != null && !"".equals(countyCode)) {
                                    List<Map<String, Object>> list = new ArrayList<>();
                                    if (segmedata != null && segmedata.size() > 0) {
                                        //分组判断，stream流
                                        Map<String, List<Map<String, Object>>> sunmapsSegmentID =
                                                segmedata.stream().collect(
                                                        Collectors.groupingBy(item -> item.get("CountyCode").toString())
                                                );
                                        list = sunmapsSegmentID.get(countyCode);
                                    }
                                    String datasize = "0";
                                    if (list != null && list.size() > 0) {
                                        for (Map<String, Object> listdata : list) {
                                            Object hldatasize = listdata.get("hldatasize");//河流对应数量
                                            Object countyCode1 = listdata.get("CountyCode");//区划编码
                                            Object hkdatasize = listdata.get("hkdatasize");//湖库对应数量
                                            datasize = String.valueOf(hkdatasize);
                                        }
                                    }
                                    dataday.setStandby1(String.valueOf(datasize));
                                }
                                if (riverID != null && !"".equals(riverID)) {
                                    dataday.setRiverid(String.valueOf(riverID));
                                }
                                if (riverName != null && !"".equals(riverName)) {
                                    dataday.setRivername(String.valueOf(riverName));
                                }
                                //上面获取对应监测均值之后下面需要计算对应的水质级别和是否超标超标倍数
                                //调用工具类返回计算标准数据
                                Map segmentStandardValuemap = new HashMap();
                                segmentStandardValuemap.put("ItemCode", itemCode);
                                segmentStandardValuemap.put("ID", id);
                                List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);

                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(avgEffectiveValue)), standards, String.valueOf(itemCode), String.valueOf(avgEffectiveValue), Integer.valueOf(String.valueOf(itemCategroy)));
                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                if (integer != null) {
                                    integer = integer;//断面计算出的级别
                                } else {
                                    //断面计算出的级别
                                    integer = 0;
                                }
                                dataday.setQualitylevel(String.valueOf(integer));
                                //转换水质级别名称
                                String LevelName = WaterLevelCompute.GetLevelName(integer, "");
                                dataday.setQualitylevelname(LevelName);
                                //判断计算级别不能为空 1.拿到对应因子是否参有断面计算如果不参与就不进行对比
                                Map<String, Object> stringObjectMap = circumferencedataitemCode(String.valueOf(itemCode), String.valueOf(avgEffectiveValue));
                                if (stringObjectMap != null && stringObjectMap.size() > 0) {
                                    Object isoverstandard1 = stringObjectMap.get("Isoverstandard1");//是否超标
                                    Object overstandardtimes1 = stringObjectMap.get("Overstandardtimes1");//超标倍数

                                    Object isoverstandard2 = stringObjectMap.get("Isoverstandard2");//
                                    Object overstandardtimes2 = stringObjectMap.get("Overstandardtimes2");

                                    Object isoverstandard3 = stringObjectMap.get("Isoverstandard3");
                                    Object overstandardtimes3 = stringObjectMap.get("Overstandardtimes3");


                                    Object isoverstandard4 = stringObjectMap.get("Isoverstandard4");
                                    Object overstandardtimes4 = stringObjectMap.get("Overstandardtimes4");

                                    Object isoverstandard5 = stringObjectMap.get("Isoverstandard5");
                                    Object overstandardtimes5 = stringObjectMap.get("Overstandardtimes5");
                                    if (overstandardtimes5 != null && !"".equals(overstandardtimes5)) {
                                        dataday.setOverstandardtimes5(String.valueOf(overstandardtimes5));
                                    }
                                    if (overstandardtimes4 != null && !"".equals(overstandardtimes4)) {
                                        dataday.setOverstandardtimes4(String.valueOf(overstandardtimes4));
                                    }
                                    if (overstandardtimes3 != null && !"".equals(overstandardtimes3)) {
                                        dataday.setOverstandardtimes3(String.valueOf(overstandardtimes3));
                                    }
                                    if (overstandardtimes2 != null && !"".equals(overstandardtimes2)) {
                                        dataday.setOverstandardtimes2(String.valueOf(overstandardtimes2));
                                    }
                                    if (overstandardtimes1 != null && !"".equals(overstandardtimes1)) {
                                        dataday.setOverstandardtimes1(String.valueOf(overstandardtimes1));
                                    }

                                    //是否超标进行判断是否数据为空
                                    if (isoverstandard1 != null && !"".equals(isoverstandard1)) {
                                        dataday.setIsoverstandard1(String.valueOf(isoverstandard1));
                                    }
                                    if (isoverstandard2 != null && !"".equals(isoverstandard2)) {
                                        dataday.setIsoverstandard2(String.valueOf(isoverstandard2));
                                    }
                                    if (isoverstandard3 != null && !"".equals(isoverstandard3)) {
                                        dataday.setIsoverstandard3(String.valueOf(isoverstandard3));
                                    }
                                    if (isoverstandard4 != null && !"".equals(isoverstandard4)) {
                                        dataday.setIsoverstandard4(String.valueOf(isoverstandard4));
                                    }
                                    if (isoverstandard5 != null && !"".equals(isoverstandard5)) {
                                        dataday.setIsoverstandard5(String.valueOf(isoverstandard5));
                                    }
                                }

                                //上面数据处理完成后进行数据判断插入
                                //数据特殊处理当前时间累计
                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemcode", itemCode);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("itemname", itemName);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("county", county);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("countycode", countyCode);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", dataday.getSampledate());
                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("segmentcategory", "3");
                                if (datatype.equals("5")) {
                                    findWq_data_basmonthlycumulativedataByConditionmap.put("segmentid", id);
                                }

                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByConditionmap(findWq_data_basmonthlycumulativedataByConditionmap);
                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                    Map<String, Object> stringObjectMap2 = wq_data_basmonthlycumulativedataByCondition.get(0);
                                    if(stringObjectMap2!=null&&stringObjectMap2.size()>0){
                                        Object id1 = stringObjectMap2.get("id");
                                        if(id1!=null&&!"".equals(id1)){
                                            dataday.setId(String.valueOf(id1));
                                            busMonthlycumulativedataMapper.updateWq_data_basmonthlycumulativedata(dataday);
                                        }
                                    }
                                } else {
                                    dataday.setId(UUID.randomUUID().toString());
                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                }
                            }
                        }
                    }
                }

            }
        }

    }


    /**
     * 根据传入的参数计算水质指数
     **/
    public void insertWq_data_basmonthlycumulatiAssessTypeCode(Map<String, Object> mapdatal, String datatype) {
        Map<String, Object> map = new HashMap<>();
        //处理断面考核类型
        String assessTypeCode = "";
        if (datatype != null && "12".equals(datatype)) {
            assessTypeCode = "0";
        }
        if (datatype != null && "13".equals(datatype)) {
            assessTypeCode = "1";
        }
        if (datatype != null && "14".equals(datatype)) {
            assessTypeCode = "2";
        }
        Map<String, Object> minmaxSampleDate = busMonthlycumulativedataMapper.minmaxSampleDate();//获取最小最大数据
        Object minSampleDate = minmaxSampleDate.get("minSampleDate");//开始月份
        Object maxSampleDate = minmaxSampleDate.get("maxSampleDate");//结束月份
        Object minyarSampleDate = minmaxSampleDate.get("minyarSampleDate");//开始年份
        Object maxyarSampleDate = minmaxSampleDate.get("maxyarSampleDate");//结束年份
        List<String> datastring = new ArrayList<>();//所有因子的水质指数集合
        //水质等级传一查询出修约需要的数据
        List<Map<String, Object>> hlroundingOffmaps = segmentFormula.wqBasStandardcategory("1", "1");
        //水质等级为三查询出水质指数计算的数据
        List<Map<String, Object>> hlindexmaps = segmentFormula.wqBasStandardcategory("1", "3");
        //水质等级传一查询出修约需要的数据
        List<Map<String, Object>> hkroundingOffmaps = segmentFormula.wqBasStandardcategory("2", "1");
        //水质等级为三查询出水质指数计算的数据
        List<Map<String, Object>> hkindexmaps = segmentFormula.wqBasStandardcategory("2", "3");

        //查询数据表中是否存在数据如果存在就查询当前月的数据，如果不存在就循环月数据进行入库
        map.put("datatype", datatype);
        List<Map<String, Object>> wq_data_basmonthlycumulativedataByConditionlist = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(map);
        Boolean moondata = true;
        if (wq_data_basmonthlycumulativedataByConditionlist != null && wq_data_basmonthlycumulativedataByConditionlist.size() > 0) {
            moondata = false;
        }
        if (moondata) {
            //获取年份
            List<String> years = DateUtils.getYears(String.valueOf(minyarSampleDate), String.valueOf(maxyarSampleDate));
            //根据上面年份进行循环
            if (years != null && years.size() > 0) {
                for (String yeardata : years) {
                    for (int i = 0; i < 12; i++) {
                        String kstime = yeardata + "-01";//开始时间
                        String jstime = null;
                        String moonjstime = null;
                        String ljmoonjstime = null;
                        if (i < 9) {
                            jstime = yeardata + "-0" + (i + 1);//结束时间
                            moonjstime = "01-0" + (i + 1);//结束时间
                            ljmoonjstime = String.valueOf((i + 1));//结束时间
                        } else {
                            jstime = yeardata + "-" + (i + 1);//结束时间
                            moonjstime = "01-" + (i + 1);//结束时间
                            ljmoonjstime = String.valueOf((i + 1));//结束时间
                        }
                        Boolean sj=true;
                        if(maxSampleDate!=null&&!"".equals(maxSampleDate)){
                            String s = String.valueOf(maxSampleDate);
                            if(s.equals(jstime)){
                                sj=false;
                            }
                        }
                        if(sj) {
                            //判断传入的数据不能为空
                            if (mapdatal != null && mapdatal.size() > 0) {
                                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                                List<Map<String, Object>> segmedata = (List<Map<String, Object>>) mapdatal.get("segmedata");//区县数据
                                List<String> hlsegmeid = (List<String>) mapdatal.get("hlsegmeid");//河流对应id
                                List<String> hksegmeid = (List<String>) mapdatal.get("hksegmeid");//湖库对应id
                                List<String> segmeid = (List<String>) mapdatal.get("alllists");//对应id

                                //调用城市计算水质指数方法根据考核类型获取宿州市的数据
                                Map<String, Object> countySectionWaterQualityIndexmap = new HashMap<>();
                                countySectionWaterQualityIndexmap.put("dataTime", jstime);
                                //断面id处理
                                countySectionWaterQualityIndexmap.put("SegmentIDs", segmeid);
                                List<String> countyCodes = new ArrayList<>();
                                if (segmedata != null && segmedata.size() > 0) { //CountyCode
                                    for (Map<String, Object> data : segmedata) {
                                        Object countyCode = data.get("CountyCode");
                                        boolean contains = countyCodes.contains(countyCode);
                                        if (contains) {
                                        } else {
                                            countyCodes.add(String.valueOf(countyCode));
                                        }
                                    }
                                }
                                countySectionWaterQualityIndexmap.put("countyCodes", countyCodes);

                                List<String> assessTypeCodes = new ArrayList<>();
                                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                                    String[] arr = assessTypeCode.split(",");
                                    assessTypeCodes = Arrays.asList(arr);
                                    countySectionWaterQualityIndexmap.put("assessTypeCodes", assessTypeCodes);

                                }
                                countySectionWaterQualityIndexmap.put("whetherYOY", "0");
                                countySectionWaterQualityIndexmap.put("accumulate", "1");
                                List<Map<String, Object>> countySectionWaterQualityIndexmaplist = maunalComparisonOfWaterQualityService.countySectionWaterQualityIndex(countySectionWaterQualityIndexmap);
                                if (countySectionWaterQualityIndexmaplist != null && countySectionWaterQualityIndexmaplist.size() > 0) {
                                    for (Map<String, Object> data : countySectionWaterQualityIndexmaplist) {
                                        Object countyCode = data.get("countyCode");
                                        Object waterQualityIndex = data.get("waterQualityIndex");
                                        if (countyCode != null && !"".equals(countyCode) && "140581".equals(countyCode)) {
                                            if (waterQualityIndex != null && !"".equals(waterQualityIndex)) {
                                                dataday.setEffectivevalue(new BigDecimal(String.valueOf(waterQualityIndex)));
                                            }
                                        }
                                    }
                                }
                                dataday.setDatatype(datatype);
                                // dataday.setEffectivevalue(new BigDecimal(index));
                                dataday.setSampledate(jstime);
                                dataday.setYeardata(yeardata);
                                dataday.setAccumulatedmonths(moonjstime);
                                dataday.setMonths(ljmoonjstime);

                                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", jstime);
                                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                                    System.out.println(findWq_data_basmonthlycumulativedataByConditionmap.toString());
                                } else {
                                    dataday.setId(UUID.randomUUID().toString());
                                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                                }

                            }
                        }
                    }
                }
            }

        } else {
            //判断传入的数据不能为空
            if (mapdatal != null && mapdatal.size() > 0) {
                //segmedata  CountyCode

                List<Map<String, Object>> segmedata = (List<Map<String, Object>>) mapdatal.get("segmedata");//区县数据
                List<String> hlsegmeid = (List<String>) mapdatal.get("hlsegmeid");//河流对应id
                List<String> hksegmeid = (List<String>) mapdatal.get("hksegmeid");//湖库对应id
                List<String> segmeid = (List<String>) mapdatal.get("alllists");//对应id
                Date date = new Date();
                SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM");
                Map<String, Object> minmaxSampleDatemap = new HashMap<>();
                minmaxSampleDatemap.put("SegmentIDs", hlsegmeid);
                Map<String, Object> stringObjectMap1 = busMonthlycumulativedataMapper.maxSampleDate(minmaxSampleDatemap);
                Object maxSampleDate1 = stringObjectMap1.get("maxSampleDate");
                // String format = dfs.format(date);
                Date parse = null;
                try {
                    parse = dfs.parse(String.valueOf(maxSampleDate1));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                String format = dfs.format(parse);
                String month = DateUtils.MONTH(format, "yyyy-MM");
                //String format = dfs.format(date);
                Integer year = DateUtils.getYear(format, "yyyy-MM");
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(parse);
                // 获取开始年份和开始月份
                //int startMonth = calendar.get(Calendar.MONTH);
                int startMonth = Integer.valueOf(month);
                Map<String, Object> deleteWq_data_basmonthlycumulativedataByIdSampleDatemap = new HashMap<>();
                deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SampleDate", maxSampleDate);
                deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("DataType", datatype);
                deleteWq_data_basmonthlycumulativedataByIdSampleDatemap.put("SegmentCategory", "1");
                BusBasmonthlycumulativedata dataday = new BusBasmonthlycumulativedata();
                int hlsize = hlsegmeid.size();
                int hksize = hksegmeid.size();

                List<String> hkindex = new ArrayList<>();//湖库水质指数
                List<String> hlindex = new ArrayList<>();//河流水质指数
                //根据上面得到的均值数据计算月累计的水质指数
                //调用完工具类后所有水质指数进行相加总和数据
                //[hlIndex 河流水质指数, hlsize 河流数量, hkIndex 湖库水质指数, hksize 湖库数量]
                //调用城市计算水质指数方法根据考核类型获取宿州市的数据
                Map<String, Object> countySectionWaterQualityIndexmap = new HashMap<>();
                countySectionWaterQualityIndexmap.put("dataTime", format);
                //断面id处理
                countySectionWaterQualityIndexmap.put("SegmentIDs", segmeid);
                List<String> countyCodes = new ArrayList<>();
                if (segmedata != null && segmedata.size() > 0) { //CountyCode
                    for (Map<String, Object> data : segmedata) {
                        Object countyCode = data.get("CountyCode");
                        boolean contains = countyCodes.contains(countyCode);
                        if (contains) {
                        } else {
                            countyCodes.add(String.valueOf(countyCode));
                        }
                    }
                }
                countySectionWaterQualityIndexmap.put("countyCodes", countyCodes);

                List<String> assessTypeCodes = new ArrayList<>();
                if (assessTypeCode != null && !"".equals(assessTypeCode)) {
                    String[] arr = assessTypeCode.split(",");
                    assessTypeCodes = Arrays.asList(arr);
                    countySectionWaterQualityIndexmap.put("assessTypeCodes", assessTypeCodes);

                }
                countySectionWaterQualityIndexmap.put("whetherYOY", "0");
                countySectionWaterQualityIndexmap.put("accumulate", "1");
                List<Map<String, Object>> countySectionWaterQualityIndexmaplist = maunalComparisonOfWaterQualityService.countySectionWaterQualityIndex(countySectionWaterQualityIndexmap);
                if (countySectionWaterQualityIndexmaplist != null && countySectionWaterQualityIndexmaplist.size() > 0) {
                    for (Map<String, Object> data : countySectionWaterQualityIndexmaplist) {
                        Object countyCode = data.get("countyCode");
                        Object waterQualityIndex = data.get("waterQualityIndex");
                        if (countyCode != null && !"".equals(countyCode) && "140581".equals(countyCode)) {
                            if(waterQualityIndex!=null&&!"".equals(waterQualityIndex)&&!"null".equals(waterQualityIndex)){
                                dataday.setEffectivevalue(new BigDecimal(String.valueOf(waterQualityIndex)));
                            }
                        }
                    }
                }

                dataday.setDatatype(datatype);
                dataday.setSampledate(year + "-" + startMonth);
                dataday.setYeardata(String.valueOf(year));
                dataday.setAccumulatedmonths("01-" + startMonth);
                dataday.setMonths(String.valueOf(startMonth));

                Map<String, Object> findWq_data_basmonthlycumulativedataByConditionmap = new HashMap<>();
                findWq_data_basmonthlycumulativedataByConditionmap.put("sampledate", year + "-" + startMonth);
                findWq_data_basmonthlycumulativedataByConditionmap.put("datatype", datatype);
                List<Map<String, Object>> wq_data_basmonthlycumulativedataByCondition = busMonthlycumulativedataMapper.findWq_data_basmonthlycumulativedataByCondition(findWq_data_basmonthlycumulativedataByConditionmap);
                if (wq_data_basmonthlycumulativedataByCondition != null && wq_data_basmonthlycumulativedataByCondition.size() > 0) {
                    System.out.println(findWq_data_basmonthlycumulativedataByConditionmap.toString());
                } else {
                    dataday.setId(UUID.randomUUID().toString());
                    busMonthlycumulativedataMapper.insertWq_data_basmonthlycumulativedata(dataday);
                }

            }
        }
    }

    /**
     * 查询是否达标和超标倍数
     **/
    public Map<String, Object> circumferencedataitemCode(String itemCode, String avgEffectiveValue) {
        Map<String, Object> map = new HashMap<>();
        DecimalFormat df = new DecimalFormat("#0.00");
        Map<String, Object> sectionStandardCalculationmap1 = new HashMap<>();
        sectionStandardCalculationmap1.put("SegmentCategory", "1");//默认
        sectionStandardCalculationmap1.put("Level", "1");//水质等级
        sectionStandardCalculationmap1.put("ItemCode", itemCode);//因子编码
        List<Map> list = publicToolsMapper.sectionStandardCalculation(sectionStandardCalculationmap1);
        if (list != null && list.size() > 0) {
            Object standardValue = list.get(0).get("StandardValue");//标准值
            Object compareMethod = list.get(0).get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
            if (compareMethod != null && !"".equals(compareMethod)) {
                if (compareMethod.equals("0")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard1", "1");
                        //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                        Double v = (Double.valueOf(String.valueOf(avgEffectiveValue)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                        String format = df.format(v);
                        map.put("Overstandardtimes1", format);
                    }
                }
                if (compareMethod.equals("1")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) <= Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard1", "1");
                    }
                }
                if (compareMethod.equals("2")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard1", "1");
                    }
                }
            }
        }


        Map<String, Object> sectionStandardCalculationmap2 = new HashMap<>();
        sectionStandardCalculationmap2.put("SegmentCategory", "1");//默认
        sectionStandardCalculationmap2.put("Level", "2");//水质等级
        sectionStandardCalculationmap2.put("ItemCode", itemCode);//因子编码
        List<Map> list2 = publicToolsMapper.sectionStandardCalculation(sectionStandardCalculationmap2);
        if (list2 != null && list2.size() > 0) {
            Object standardValue = list2.get(0).get("StandardValue");//标准值
            Object compareMethod = list2.get(0).get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
            if (compareMethod != null && !"".equals(compareMethod)) {
                if (compareMethod.equals("0")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard2", "1");
                        //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                        Double v = (Double.valueOf(String.valueOf(avgEffectiveValue)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                        String format = df.format(v);
                        map.put("Overstandardtimes2", format);
                    }
                }
                if (compareMethod.equals("1")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) <= Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard2", "1");
                    }
                }
                if (compareMethod.equals("2")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard2", "1");
                    }
                }
            }
        }

        Map<String, Object> sectionStandardCalculationmap3 = new HashMap<>();
        sectionStandardCalculationmap3.put("SegmentCategory", "1");//默认
        sectionStandardCalculationmap3.put("Level", "3");//水质等级
        sectionStandardCalculationmap3.put("ItemCode", itemCode);//因子编码
        List<Map> list3 = publicToolsMapper.sectionStandardCalculation(sectionStandardCalculationmap3);
        if (list3 != null && list3.size() > 0) {
            Object standardValue = list3.get(0).get("StandardValue");//标准值
            Object compareMethod = list3.get(0).get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
            if (compareMethod != null && !"".equals(compareMethod)) {
                if (compareMethod.equals("0")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard3", "1");
                        //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                        Double v = (Double.valueOf(String.valueOf(avgEffectiveValue)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                        String format = df.format(v);
                        map.put("Overstandardtimes3", format);
                    }
                }
                if (compareMethod.equals("1")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) <= Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard3", "1");
                    }
                }
                if (compareMethod.equals("2")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard3", "1");
                    }
                }
            }
        }
        Map<String, Object> sectionStandardCalculationmap4 = new HashMap<>();
        sectionStandardCalculationmap4.put("SegmentCategory", "1");//默认
        sectionStandardCalculationmap4.put("Level", "4");//水质等级
        sectionStandardCalculationmap4.put("ItemCode", itemCode);//因子编码
        List<Map> list4 = publicToolsMapper.sectionStandardCalculation(sectionStandardCalculationmap4);
        if (list4 != null && list4.size() > 0) {
            Object standardValue = list4.get(0).get("StandardValue");//标准值
            Object compareMethod = list4.get(0).get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
            if (compareMethod != null && !"".equals(compareMethod)) {
                if (compareMethod.equals("0")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard4", "1");
                        //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                        Double v = (Double.valueOf(String.valueOf(avgEffectiveValue)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                        String format = df.format(v);
                        map.put("Overstandardtimes4", format);
                    }
                }
                if (compareMethod.equals("1")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) <= Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard4", "1");
                    }
                }
                if (compareMethod.equals("2")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard4", "1");
                    }
                }
            }
        }

        Map<String, Object> sectionStandardCalculationmap5 = new HashMap<>();
        sectionStandardCalculationmap5.put("SegmentCategory", "1");//默认
        sectionStandardCalculationmap5.put("Level", "5");//水质等级
        sectionStandardCalculationmap5.put("ItemCode", itemCode);//因子编码
        List<Map> list5 = publicToolsMapper.sectionStandardCalculation(sectionStandardCalculationmap5);
        if (list5 != null && list5.size() > 0) {
            Object standardValue = list5.get(0).get("StandardValue");//标准值
            Object compareMethod = list5.get(0).get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
            if (compareMethod != null && !"".equals(compareMethod)) {
                if (compareMethod.equals("0")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard5", "1");
                        //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                        Double v = (Double.valueOf(String.valueOf(avgEffectiveValue)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                        String format = df.format(v);
                        map.put("Overstandardtimes5", format);
                    }
                }
                if (compareMethod.equals("1")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) <= Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard5", "1");
                    }
                }
                if (compareMethod.equals("2")) {
                    if (Double.valueOf(String.valueOf(avgEffectiveValue)) > Double.valueOf(String.valueOf(standardValue))) {
                        map.put("Isoverstandard5", "1");
                    }
                }
            }
        }
        return map;
    }

    @Override
    public void selectSegmentData() {
        List<Map<String,Object>> list=  busMonthlycumulativedataMapper.getSegmentData();

        System.out.println(list);
    }

    @Override
    public void moonAssessTypeSegmens() {
        //根据国 省 市 全部考核断面  手工断面 类型查询到对应断面id AssessTownCodesegment 考核  WqBasSegmentNameAll 手工
        Map<String, Object> AssessTownCodesegmentmap = new HashMap<>();
        AssessTownCodesegmentmap.put("Type", "CountyCode");
        //查询全部考核断面
        List<Map<String, Object>> allassessTypelist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> allassessTypesegmenfenzu = segmentFormula.Segmenfenzu(allassessTypelist);
        AssessTownCodesegmentmap.put("AssessTypeCode", "0");//查询国考数据
        List<Map<String, Object>> countrylist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> countrylistsegmenfenzu = segmentFormula.Segmenfenzu(countrylist);
        AssessTownCodesegmentmap.put("AssessTypeCode", "1");//查询省考数据
        List<Map<String, Object>> economizelist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> economizelistsegmenfenzu = segmentFormula.Segmenfenzu(economizelist);

        AssessTownCodesegmentmap.put("AssessTypeCode", "2");//查询市考数据
        List<Map<String, Object>> marketlist = segmentUtliService.AssessTownCodesegment(AssessTownCodesegmentmap);
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> marketlistsegmenfenzu = segmentFormula.Segmenfenzu(marketlist);

        Map<String, Object> WqBasSegmentNameAllmap = new HashMap<>();
        WqBasSegmentNameAllmap.put("segmentType", "IsDrink");//查询所有手工断面
        //WqBasSegmentNameAllmap.put("segmentTypes", "IsManualIsDrink");//查询所有手工断面
        WqBasSegmentNameAllmap.put("semen", "IsManual");//查询所有手工断面
        List<Map<String, Object>> WqBasSegmentNameAlllistdata = new ArrayList<>();
        List<Map> WqBasSegmentNameAlllist = segmentUtliService.WqBasSegmentidall(WqBasSegmentNameAllmap);
        if (WqBasSegmentNameAlllist != null && WqBasSegmentNameAlllist.size() > 0) {
            for (Map data : WqBasSegmentNameAlllist) {
                WqBasSegmentNameAlllistdata.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> WqBasSegmentNameAlllistsegmenfenzu = segmentFormula.Segmenfenzu(WqBasSegmentNameAlllistdata);


        //全部考核断面
        insertWq_data_basmonthlycumulativedata(allassessTypesegmenfenzu, "3");
        //手工断面
        insertWq_data_basmonthlycumulativedata(WqBasSegmentNameAlllistsegmenfenzu, "4");
        //不同断面数据入库
        insertWq_data_basmonthlycumulativedata(WqBasSegmentNameAlllistsegmenfenzu, "5");


        List<Map<String, Object>> gslist = new ArrayList<>();
        if (countrylist != null && countrylist.size() > 0) {
            for (Map<String, Object> data : countrylist) {
                gslist.add(data);
            }
        }
        if (economizelist != null && economizelist.size() > 0) {
            for (Map<String, Object> data : economizelist) {
                gslist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> gssegmenfenzu = segmentFormula.Segmenfenzu(gslist);
        //国省
        insertWq_data_basmonthlycumulativedata(gssegmenfenzu, "6");
        //国市
        List<Map<String, Object>> gshilist = new ArrayList<>();
        if (countrylist != null && countrylist.size() > 0) {
            for (Map<String, Object> data : countrylist) {
                gshilist.add(data);
            }
        }
        if (marketlist != null && marketlist.size() > 0) {
            for (Map<String, Object> data : marketlist) {
                gshilist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> gshilistsegmenfenzu = segmentFormula.Segmenfenzu(gshilist);
        insertWq_data_basmonthlycumulativedata(gshilistsegmenfenzu, "7");
        //省市
        List<Map<String, Object>> sshilist = new ArrayList<>();
        if (economizelist != null && economizelist.size() > 0) {
            for (Map<String, Object> data : economizelist) {
                sshilist.add(data);
            }
        }
        if (marketlist != null && marketlist.size() > 0) {
            for (Map<String, Object> data : marketlist) {
                sshilist.add(data);
            }
        }
        //调用工具类进行分组数据河流/湖库id
        Map<String, Object> sshilistsegmenfenzu = segmentFormula.Segmenfenzu(sshilist);
        insertWq_data_basmonthlycumulativedata(sshilistsegmenfenzu, "8");

        //国考断面数据处理
        insertWq_data_basmonthlycumulativedata(countrylistsegmenfenzu, "9");
        //省考
        insertWq_data_basmonthlycumulativedata(economizelistsegmenfenzu, "10");
        //市考
        insertWq_data_basmonthlycumulativedata(marketlistsegmenfenzu, "11");

    }

}
